home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group00b.txt / 000128_icon-group-sender_Mon Oct 30 13:12:42 2000.msg < prev    next >
Internet Message Format  |  2001-01-03  |  3KB

  1. Return-Path: <icon-group-sender>
  2. Received: (from root@localhost)
  3.     by baskerville.CS.Arizona.EDU (8.11.1/8.11.1) id e9UKCYJ06208
  4.     for icon-group-addresses; Mon, 30 Oct 2000 13:12:34 -0700 (MST)
  5. Message-Id: <200010302012.e9UKCYJ06208@baskerville.CS.Arizona.EDU>
  6. From: symbiot@my-deja.com
  7. X-Newsgroups: comp.lang.icon
  8. Subject: How would the experts handle this...??
  9. Date: Mon, 30 Oct 2000 19:13:49 GMT
  10. X-Article-Creation-Date: Mon Oct 30 19:13:49 2000 GMT
  11. X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows 95; DigExt)
  12. X-Http-Proxy: 1.0 SRVPROXY, 1.0 x67.deja.com:80 (Squid/1.1.22) for client 208.51.185.226
  13. X-MyDeja-Info: XMYDJUIDsymbiot
  14. To: icon-group@cs.arizona.edu
  15. Errors-To: icon-group-errors@cs.arizona.edu
  16. Status: RO
  17. Content-Length: 2223
  18.  
  19. Greetings! And welcome to my latest edition of "Questions from the
  20. Newbie"
  21.  
  22. The situation is this:
  23.  
  24. I wish to scan thru a file and determine how letters "connect" with one
  25. another. By that I mean that for every letter of the alphabet, I would
  26. like to compile two lists: one containing all the letters which apper
  27. to the right of the given letter, and another for all those appearing
  28. to the left.
  29.  
  30. Exmaple:
  31. For the line....
  32.  
  33. "Cable television programming is...."
  34.  
  35. The output would might look something like:
  36.  
  37. A:  left- Cr
  38.     right- bm
  39.  
  40. B:  left- a
  41.     right- l
  42. .
  43. .
  44. .
  45. I:   left- vsm(blank)
  46.      right- sns
  47.  
  48. etc etc etc
  49.  
  50. Here's how I have tackled the problem:
  51.  
  52. while line := read(data) do
  53. {
  54.    index := 0
  55.    while index <= *line do
  56.    {
  57.  
  58.    if not(line[index+1] == " ") then
  59.         {
  60.  
  61.         centerchar := line[index+1]
  62.  
  63.     leftchar[centerchar] := leftchar[centerchar] || line[index]
  64.     rightchar[centerchar] := rightchar[centerchar] || line[index +2]
  65.  
  66.     } #if not....
  67.  
  68.     index +:= 1
  69.     # do it again
  70.    }# end (while index <= *line)
  71.  
  72. }# end (while line := read(data))
  73.  
  74. #generate output
  75. write(output,"LETTERS ORGANIZED BY CENTER CHARACTER FOR FILE ",filename)
  76.  
  77. index := 0
  78. while index <= 52 do
  79. {
  80.  
  81.    if ((*leftchar[&letters[index]] > 1) | (*rightchar[&letters[index]]
  82. > 1)) then
  83.      {
  84.      write(output,leftchar[&letters[index]])
  85.      write(output,&letters[index])
  86.      write(output,rightchar[&letters[index]])
  87.      }  # end if
  88.  
  89.    write(output," ") #add blank line to output for clarity
  90.    index +:= 1
  91. } # end while index
  92.  
  93. -----
  94. Thus far, I have been roundly criticized by icon afficiandos for my use
  95. of explicit indexing. It seems to me an intuitive way to handle the
  96. problems I've faced and makes the program "readable" to the layman.
  97.  
  98. But, be that as it may, I'm curious as to how those "in the know" would
  99. handle this problem in a more "icon-esque" fashion.
  100.  
  101. Your suggestions are greatly appreciated.
  102.  
  103. Thanx!!
  104.  
  105.  
  106. --
  107. "Credibility depends on two semiconflicting rules. First, the system
  108. must be complicated enough to seem scientific. And second, the results
  109. must match, more or less, people's nonscientific prejudices."
  110.  
  111. Nicholas Thompson
  112. Washington Monthly
  113. 14 Sep 00
  114.  
  115.  
  116. Sent via Deja.com http://www.deja.com/
  117. Before you buy.
  118.